package Text26;

import java.util.*;

public class Main {
    static int N = 1000010;
    static int[] p = new int[N];
    static int[] t = new int[N];
    static int[] a = new int[N];//p-t
    static int[] b = new int[N];

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        for (int i = 1; i <= n; i++) {
            p[i] = in.nextInt();
        }
        for (int i = 1; i <= n; i++) {
            t[i] = in.nextInt();
        }
        for (int i = 1; i <= n; i++) {
            a[i] = p[i] - t[i];
        }
        int res = 0;
        for (int i = 1; i <= n + 1; i++) {
            b[i] = a[i] - a[i - 1];
            if (b[i] > 0) {
                res+=b[i];
            }
        }
        System.out.println(res);
    }
}

